package com.eqdd.yiqidian.ui.gongneng.renshi.train;

import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;

import com.eqdd.nextinputs.StaticScheme;
import com.eqdd.yiqidian.R;
import com.eqdd.yiqidian.RecyclerViewCustom;
import com.eqdd.yiqidian.base.AppConstent;
import com.eqdd.yiqidian.base.Config;
import com.eqdd.yiqidian.bean.rebuild.TrainPlanInfoBean;
import com.eqdd.yiqidian.bean.rebuild.slimedit.SlimEditChooseBean;
import com.eqdd.yiqidian.bean.rebuild.slimedit.SlimEditEnterBean;
import com.eqdd.yiqidian.bean.rebuild.slimedit.SlimEditHintBean;
import com.eqdd.yiqidian.bean.rebuild.slimedit.SlimEditTimeBean;
import com.eqdd.yiqidian.bean.rebuild.slimedit.SlimEditVEnterBean;
import com.eqdd.yiqidian.http.DialogCallBack;
import com.eqdd.yiqidian.http.HttpConfig;
import com.eqdd.yiqidian.http.HttpResult;
import com.eqdd.yiqidian.ui.base.SlimBaseMultiEditActivity;
import com.eqdd.yiqidian.ui.mine.UserCardActivity;
import com.eqdd.yiqidian.ui.mine.renwu.TextActivity;
import com.eqdd.yiqidian.utils.ToastUtil;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;

/**
 * @author吕志豪 .
 * @date 17-12-7  下午4:43.
 * Github :https://github.com/lvzhihao100
 * E-Mail：1030753080@qq.com
 * 简书 :http://www.jianshu.com/u/6e525b929aac
 */

public class TrainPlanInfoActivity extends SlimBaseMultiEditActivity {

    private RecyclerViewCustom dataBinding;
    private int id;
    private Bundle bundle;
    private TrainPlanInfoBean items;

    @Override
    public void initBinding() {
        dataBinding = DataBindingUtil.setContentView(this, R.layout.activity_recyclerview);
        initTopTitleBar(View.VISIBLE, "培训计划详情");
    }

    @Override
    protected RecyclerView initRecyclerView() {
        return dataBinding.recyclerView;
    }

    @Override
    public void itemClick(int p) {

//        switch (slimAdapterEx.getDataItem(p).getPosition()) {
//            case 2:
//                bundle = new Bundle();
//                bundle.putString(Config.TITLE, "培训对象");
//                bundle.putString(Config.CONTENT, items.getTrainees());
//                startActivity(TextActivity.class, bundle);
//                break;
//            case 4:
//                if (!TextUtils.isEmpty(items.getTeacherGuid().trim())) {
//                    bundle = new Bundle();
//                    bundle.putString(Config.GUID, items.getTeacherGuid());
//                    startActivity(UserCardActivity.class, bundle);
//                }
//                break;
//        }
    }

    @Override
    protected void loadNetData() {

        OkGo.<HttpResult<TrainPlanInfoBean>>post(HttpConfig.BASE_URL + HttpConfig.TRAIN_PLAN_INFO)
                .params("userGuid", AppConstent.user.getGuid())
                .params("comid", AppConstent.user.getCompanyId())
                .params("planId", id)
                .execute(new DialogCallBack<HttpResult<TrainPlanInfoBean>>(TrainPlanInfoActivity.this) {
                    @Override
                    public void onSuccess(Response<HttpResult<TrainPlanInfoBean>> response) {
                        HttpResult<TrainPlanInfoBean> httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            items = httpResult.getItems();
                            datas.add(new SlimEditHintBean("培训主题", items.getTheTheme(), 0));
                            datas.add(new SlimEditHintBean("培训类别", items.getTheCategory(), 1));
                            datas.add(new SlimEditHintBean("培训对象", items.getTrainees(), 2));
                            datas.add(new SlimEditHintBean("费用预算", items.getBudgetedExpense() + "元", 5));
                            datas.add(new SlimEditHintBean("培训人数", items.getNumOfReceivePerson() + "人", 3));
                            datas.add(new SlimEditHintBean("人均费用", items.getPerCapitaCost() + "元", 6));
                            datas.add(new SlimEditHintBean("培训老师", items.getTeacherName(), 4));
                            datas.add(new SlimEditHintBean("学习形式", items.getLearningModality(), 9));
                            datas.add(new SlimEditVEnterBean("培训时间", items.getTheTrainTime().replace(",","\r\n"), 7,true,""));
                            slimAdapterEx.updateData(datas);
                        }
                    }
                });
    }

    @Override
    protected void setEditBeans() {
        id = getIntent().getIntExtra(Config.ID, 0);
        isSave = false;
        isRead = false;

    }
}
